package tcards.android;

import models.AircraftTcard;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

public class AirFieldList extends LinearLayout {
	private GeneralFieldList mGeneralList;
	private GroupFieldList   mGroupList;
	private TextField        mPilotName;
	private TextField        mDestination;
	private TextField        mManufacturer;
	
	public AirFieldList(Context context) {
		this(context, null, 0);
	}

	public AirFieldList(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public AirFieldList(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		LayoutInflater li = LayoutInflater.from(context);
		addView(li.inflate(R.layout.air_field_list, this, false));
		
		mGeneralList  = (GeneralFieldList) findViewById(R.id.airGeneralList);
		mGroupList    = (GroupFieldList)   findViewById(R.id.airGroupList);
		mPilotName    = (TextField)        findViewById(R.id.airPilotNameField);
		mDestination  = (TextField)        findViewById(R.id.airDestinationField);
		mManufacturer = (TextField)        findViewById(R.id.manufacturerField);
	}
	
	public void setTcardFields(AircraftTcard tcard) {
		mGeneralList.setTcardFields(tcard);
		mGroupList.setTcardFields(tcard);
		tcard.setPilotName(mPilotName.getTextValue());
		tcard.setDestinationPoint(mDestination.getTextValue());
		tcard.setManufacturer(mManufacturer.getTextValue());
	}
	
	public void setListFields(AircraftTcard tcard) {
		mGeneralList.setListFields(tcard);
		mGroupList.setListFields(tcard);
		mPilotName.setTextValue(tcard.getPilotName());
		mDestination.setTextValue(tcard.getDestinationPoint());
		mManufacturer.setTextValue(tcard.getManufacturer());
	}
	
	public GeneralFieldList getGeneralList() {
		return mGeneralList;
	}
	
	public GroupFieldList getGroupList() {
		return mGroupList;
	}
	
	public TextField getPilotName() {
		return mPilotName;
	}
	
	public TextField getDestination() {
		return mDestination;
	}
	
	public TextField getManufacturer() {
		return mManufacturer;
	}
}